<?php
/**
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
*/
function insertDataCall($adid) {
    global $db,$dbpre;

    $info = $db->get_one("SELECT * FROM {$dbpre}ads WHERE adid='$adid'");
    if(empty($info)) return;
    $dc = array(
        'module' => 'ads',
        'name' => $info['subject'],
        'fun' => 'sql',
        'var' => 'mydata',
        'expression' => 
        array (
          'cachetime' => '5000',
          'from' => '{dbpre}ads',
          'select' => '*',
          'where' => 'adid=\''.$adid.'\'',
          'other' => '',
          'orderby' => 'adid',
          'limit' => '0,1',
        ),
        'tplname' => 'ad_div',
        'empty_tplname' => 'empty_ad_div',
    );
    $callid = createDatacall($dc,'sql',$info['callid']);
    cache_datacall();
    if(!empty($callid) && $callid != $info['callid']) {
        $db->update("UPDATE {$dbpre}ads SET callid='$callid' WHERE adid='$adid'");
    }
}

function convertToCode($adtype, & $params) {
    $code='';
    if($adtype==1) {
        $code='<a href="'.$params['font_href'].'" target="_blank"><span style="font-size:'.$params['font_size'].'px;">'.$params['font_title'].'</span></a>';
    } elseif($adtype==2) {
        $code='<a href="'.$params['img_href'].'" title="'.$params['img_title'].'" target="_blank"><img src="'.$params['img_src'].'" width="'.$params['img_width'].'" height="'.$params['img_height'].'" /></a>';
    } elseif($adtype==3) {
        $code='<embed width="'.$params['flash_width'].'" height="'.$params['flash_height'].'" src="'.$params['flash_src'].'" type="application/x-shockwave-flash"></embed>';
    } elseif($adtype==4) {
        $code=$params['code'];
    }
    return $code;
}
?>